package mn.more.wits.server.model;

import java.util.HashMap;
import java.util.Map;

/**
 * @author $Author: mikeliucc $
 * @version $Id: WitsRole.java 5 2008-09-01 12:08:42Z mikeliucc $
 */
public final class WitsRole {

	public static final int EXAM_TAKER_ID = 5;
	public static final int EXAM_CREATOR_ID = 6;
	public static final int ADMINISTRATOR_ID = 2;
	public static final int INVIGILATOR_ID = 7;

	private static Map<String, WitsRole> roles =
		new HashMap<String, WitsRole>();
	public static final WitsRole EXAM_TAKER = new WitsRole(EXAM_TAKER_ID, "Exam Taker");
	public static final WitsRole EXAM_CREATOR = new WitsRole(EXAM_CREATOR_ID, "Exam Creator");
	public static final WitsRole ADMIN = new WitsRole(ADMINISTRATOR_ID, "Administrator");
	public static final WitsRole INVIGILATOR = new WitsRole(INVIGILATOR_ID, "Invigilator");

	private int id;
	private String name;

	private WitsRole(int id, String name) {
		if (roles == null) { roles = new HashMap<String, WitsRole>(); }
		this.id = id;
		this.name = name;
		roles.put(name, this);
	}

	public int getId() { return id; }

	public String getName() { return name; }

	public static WitsRole getRole(String name) { return roles.get(name); }
}
